﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
// namespace .net
using System.Net;
using System.Net.Mail;

namespace MediaRegister
{
    public partial class Mail : Form
    {
        public Mail()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                
                MailMessage msg = new MailMessage();
                MailAddress from = new MailAddress("amjad90@hotmail.se");
                MailAddress to = new MailAddress(textTo.Text);
                
                MailAddress cc = new MailAddress(textCc.Text);

                SmtpClient smtp = new SmtpClient();
                msg.Subject = textSubject.Text;
                msg.SubjectEncoding = Encoding.UTF8;
                msg.Body = textBody.Text;
                msg.BodyEncoding = Encoding.UTF8;
                msg.From = from;
                msg.To.Add(to);
               
                msg.CC.Add(cc);
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
               
                smtp.Credentials = new  NetworkCredential("amjad9093@gmail.com", "amjad021");
                smtp.EnableSsl = true;
                smtp.Send(msg);
                MessageBox.Show("Your message has been send!");
            }
            catch (SyntaxErrorException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        
        

        

       
        

    }
}

        

